Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
turndown-plugin-gfm
Advanced tools
The turndown-plugin-gfm package is a plugin for Turndown, a library that converts HTML into Markdown. This plugin specifically adds support for GitHub Flavored Markdown (GFM) to Turndown, enabling the conversion of HTML elements that are unique to GFM.
Strikethrough
This feature converts HTML <del> tags into GFM strikethrough syntax using double tildes (~~).
const TurndownService = require('turndown');
const gfm = require('turndown-plugin-gfm').gfm;
const turndownService = new TurndownService();
turndownService.use(gfm);
const html = '<p><del>Strikethrough text</del></p>';
const markdown = turndownService.turndown(html);
console.log(markdown); // Outputs: '~~Strikethrough text~~'
Tables
This feature converts HTML tables into GFM table syntax, which is a common requirement for documentation and README files.
const TurndownService = require('turndown');
const gfm = require('turndown-plugin-gfm').gfm;
const turndownService = new TurndownService();
turndownService.use(gfm);
const html = '<table><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Data 1</td><td>Data 2</td></tr></tbody></table>';
const markdown = turndownService.turndown(html);
console.log(markdown); // Outputs: '| Header 1 | Header 2 |
| --- | --- |
| Data 1 | Data 2 |'
Task Lists
This feature converts HTML checkboxes within list items into GFM task list syntax, which is useful for project management and to-do lists.
const TurndownService = require('turndown');
const gfm = require('turndown-plugin-gfm').gfm;
const turndownService = new TurndownService();
turndownService.use(gfm);
const html = '<ul><li><input type="checkbox" checked> Task 1</li><li><input type="checkbox"> Task 2</li></ul>';
const markdown = turndownService.turndown(html);
console.log(markdown); // Outputs: '- [x] Task 1
- [ ] Task 2'
Showdown is a bidirectional converter that can convert HTML to Markdown and vice versa. It supports a wide range of Markdown flavors, including GFM. Compared to turndown-plugin-gfm, Showdown is more versatile as it can handle both conversions.
Markdown-it is a Markdown parser that can be extended with plugins to support GFM and other Markdown flavors. While it primarily focuses on parsing Markdown to HTML, it can be extended to support HTML to Markdown conversion as well. It is highly customizable and fast.
Remark is a Markdown processor powered by plugins. It can parse, transform, and compile Markdown. With the appropriate plugins, it can support GFM and convert HTML to Markdown. Remark is known for its flexibility and extensive plugin ecosystem.
A Turndown plugin which adds GitHub Flavored Markdown extensions.
npm:
npm install turndown-plugin-gfm
Browser:
<script src="https://unpkg.com/turndown/dist/turndown.js"></script>
<script src="https://unpkg.com/turndown-plugin-gfm/dist/turndown-plugin-gfm.js"></script>
// For Node.js
var TurndownService = require('turndown')
var turndownPluginGfm = require('turndown-plugin-gfm')
var gfm = turndownPluginGfm.gfm
var turndownService = new TurndownService()
turndownService.use(gfm)
var markdown = turndownService.turndown('<strike>Hello world!</strike>')
turndown-plugin-gfm is a suite of plugins which can be applied individually. The available plugins are as follows:
strikethrough
(for converting <strike>
, <s>
, and <del>
elements)tables
taskListItems
gfm
(which applies all of the above)So for example, if you only wish to convert tables:
var tables = require('turndown-plugin-gfm').tables
var turndownService = new TurndownService()
turndownService.use(tables)
turndown-plugin-gfm is copyright © 2017+ Dom Christie and released under the MIT license.
FAQs
Turndown plugin to add GitHub Flavored Markdown extensions.
The npm package turndown-plugin-gfm receives a total of 235,009 weekly downloads. As such, turndown-plugin-gfm popularity was classified as popular.
We found that turndown-plugin-gfm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.